package com.dbpms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dbpms.mapper.ChamberFloorMapper;
import com.dbpms.mapper.ChamberMapper;
import com.dbpms.mapper.ChamberTypeMapper;
import com.dbpms.pojo.*;
import com.dbpms.service.IChamberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChamberServiceImpl extends ServiceImpl<ChamberMapper, ChamberInfo> implements IChamberService {




    /**
     * 获取全部寝室楼信息
     * @return
     */
    @Resource
    private ChamberFloorMapper chamberFloorMapper;
    @Override
    public List<Chamberfloorinfo> queryAllChtFloorInfo() {
        LambdaQueryWrapper<Chamberfloorinfo> wrapper = new LambdaQueryWrapper<Chamberfloorinfo>();
        return chamberFloorMapper.selectList(wrapper);
    }

    /**
     * 获取全部寝室类型信息
     * @return
     */
    @Resource
    private ChamberTypeMapper chamberTypeMapper;
    @Override
    public List<Chambertypeinfo> queryChtTypeInfo() {
        LambdaQueryWrapper<Chambertypeinfo> wrapper = new LambdaQueryWrapper<Chambertypeinfo>();
        return chamberTypeMapper.selectList(wrapper);
    }

    /**
     * 删除寝室信息
     * @param Chamber_id
     * @return
     */
    @Override
    public boolean deleteChamberInfo(int Chamber_id)  {

        return removeById(Chamber_id);
    }

    /**
     * 新增寝室信息
     * @param chInfo
     * @return
     */
    @Override
    public boolean addChamberInfo(ChamberInfo chInfo) {
        return save(chInfo);
    }

    /**
     * 修改寝室信息
     * @param chInfo
     * @return
     */
    @Override
    public boolean updateChamberInfo(ChamberInfo chInfo) {

        boolean pd = lambdaUpdate()
                .set(ChamberInfo::getChamberFloorId,chInfo.getChamberFloorId())
                .set(ChamberInfo::getChamberHotelNumber,chInfo.getChamberHotelNumber())
                .set(ChamberInfo::getChamberFloor,chInfo.getChamberFloor())
                .set(ChamberInfo::getChamberTypeId,chInfo.getChamberTypeId())
                .set(ChamberInfo::getChamberBed,chInfo.getChamberBed())
                .eq(ChamberInfo::getChamberId,chInfo.getChamberId())
                .update();

        return pd;
    }

    @Override
    public List<StudentInfo> queryChamberNum_Stu(int chamber_id) {
        return null;
    }

    /**
     * 根据寝室楼与楼层查找寝室号信息
     * @param Chamber_floor_id
     * @param Chamber_floor
     * @return
     */
    @Override
    public List<ChamberInfo> queryApplyChtInfo(int Chamber_floor_id, int Chamber_floor) {
        return lambdaQuery()
                .eq(ChamberInfo::getChamberFloorId,Chamber_floor_id)
                .eq(ChamberInfo::getChamberFloor, Chamber_floor)
                .apply("chamber_bed >chamber_number_of_people")
                .list();
    }

    @Override
    public int addSleepAdjustmentApplyInfo(TransferChamberInfo info) {
        return 0;
    }

    @Override
    public List<TransferChamberInfo> queryChtApplyScheduleInfo(int stu_id) {
        return null;
    }

    @Override
    public List<TransferChamberInfo> queryChtApplyInScheduleInfo() {
        return null;
    }

    @Override
    public int successAdjustmentApplyInfo(int apply_other_chamber__id, int old_chamber_id, int new_chamber_id, int stu_id) {
        return 0;
    }

    @Override
    public int dangerAdjustmentApplyInfo(int apply_other_chamber__id) {
        return 0;
    }
}
